<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Receipt extends CI_Model {
  
  var $table_name = 'receipts';

  function addReceipt($action, $number, $amount, $receipt, $date, $code, $type) {
        
    $data = array('action'=>$action, 'number'=>$number, 'amount'=>$amount, 'receipt'=>$receipt,
      'date'=>$date, 'code'=>$code, 'type'=>$type
    );
    $this->db->insert($this->table_name, $data);
    $this->db->where($data);
    $res = $this->db->get($this->table_name);
    return $res->result();
  }

  function editReceiptCode($receipt, $code,$date,$type) {
        
    $data = array(
      'code'=>$code,
      'date'=>$date
    );
    
    $this->db->where('receipt',$receipt);
    $this->db->where('type',$type);
    $this->db->set($data);
    $this->db->update($this->table_name);
  }


  function getReceipt($receipt,$type){
    $this->db->where('receipt', $receipt);
    $this->db->where('type', $type);
    $res = $this->db->get($this->table_name);
    return $res->result();
  }


}